package com.jyniubi.core.controller.admin;


import com.jyniubi.base.result.R;
import com.jyniubi.core.pojo.entity.BorrowInfo;
import com.jyniubi.core.pojo.vo.BorrowInfoApprovalVO;
import com.jyniubi.core.pojo.vo.BorrowInfoVO;
import com.jyniubi.core.service.BorrowInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 借款信息表 前端控制器
 * </p>
 *
 * @author jyzhang
 * @since 2024-04-27
 */
@Api(tags = "管理台借款信息")
@RestController
@RequestMapping("/admin/core/borrowInfo")
public class AdminBorrowInfoController {
    @Resource
    private BorrowInfoService borrowInfoService;

    @ApiOperation("借款审批")
    @PostMapping("/approval")
    public R approval(@RequestBody BorrowInfoApprovalVO borrowInfoApprovalVO){
        borrowInfoService.approval(borrowInfoApprovalVO);
        return R.ok();
    }
    @ApiOperation("借款列表")
    @GetMapping("/getBorrowInfoVOs")
    public R getBorrowInfoVOs(){
        List<BorrowInfoVO> borrowInfoVOS =  borrowInfoService.getBorrowInfoVOs();
        return R.ok().data("items",borrowInfoVOS);
    }
    @ApiOperation("借款列表详情")
    @GetMapping("/getBorrowInfoDetails/{id}")
    public R getBorrowInfoDetails(@PathVariable("id")String id){
        //业务执行需要返回两个vo类对象所以使用map
        Map<String,Object> map = borrowInfoService.getBorrowInfoDetails(id);
        return R.ok().data("items",map);
    }


}

